var t = (0, require("../../../@babel/runtime/helpers/interopRequireDefault").default)(require("../../../utils/util")),
  a = new(require("../../../utils/http").HTTP);
Page({
  data: {
    num: 1,
    bad: 1,
    daily: !0,
    month: t.default.formatDates(new Date),
    nowtime: t.default.formatDate(new Date),
    attractDay: !0,
    addtoday: {
      add: "今日新增",
      follow: "今日跟进",
      exactly: "今日核名",
      addnow: "当日新增"
    },
    semicircle: !1,
    date: 1,
    section: !1
  },
  changeOil: function (t) {
    var e = this;
    wx.showLoading({
        title: "加载中"
      }),
      setTimeout((function () {
        wx.hideLoading()
      }), 700),
      e.setData({
        num: t.target.dataset.num,
        addtoday: {
          add: "今日新增",
          follow: "今日跟进",
          exactly: "今日核名",
          addnow: "当日新增"
        },
        section: !1
      }),
      2 == e.data.num ? (e.setData({
        daily: !1,
        addtoday: {
          add: "本月新增",
          follow: "本月跟进",
          exactly: "本月核名",
          addnow: "本月新增"
        }
      }), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: e.data.month,
          arr: 3
        }
      }).then((function (t) {
        t.data.length > 0 ? e.setData({
            total: {
              jda: t.data[0].jda
            }
          }) : e.setData({
            total: {
              jda: 0
            }
          }),
          a.request({
            url: "https://www.qlsyyun.com:3000/trader/lxb",
            data: {
              arr: 2,
              month: e.data.month
            }
          }).then((function (t) {
            if (0 == t.data.length)
              e.setData({
                lxb: 0,
                perfumeNum: 1
              });
            else {
              e.setData({
                lxb: t.data[0].lxb
              });
              var a = Number((e.data.lxb / e.data.total.jda).toFixed(2));
              e.data.lxb > e.data.total.jda ? e.setData({
                perfumeNum: 2
              }) : e.setData({
                perfumeNum: 1 + a
              })
            }
          }))
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: e.data.month,
          arr: 3
        }
      }).then((function (t) {
        0 == t.data.length ? e.setData({
          jda: 0,
          jdba: 0,
          jdd: 0
        }) : e.setData({
          jda: t.data[0].jda,
          jdba: t.data[0].jdba,
          jdd: t.data[0].jdd
        })
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: e.data.month,
          arr: 5
        }
      }).then((function (t) {
        0 == t.data.length ? e.setData({
          attractDay: !1
        }) : e.setData({
          attractDay: !0,
          attract: t.data
        })
      }))) : (e.setData({
        daily: !0
      }), e.selectDay(t))
  },
  changeOils: function (e) {
    var d = this;
    wx.showLoading({
        title: "加载中"
      }),
      setTimeout((function () {
        wx.hideLoading()
      }), 700),
      d.setData({
        date: e.target.dataset.date
      }),
      1 == d.data.date && (d.setData({
        section: !0,
        daily: !0
      }), a.request({
        url: "https://www.qlsyyun.com:3000/trader/branch",
        data: {
          day: t.default.formatDate(new Date).slice(8, 11),
          month: e.detail.month,
          arr: 2
        }
      }).then((function (t) {
        0 == t.data.length ? d.setData({
          attractDay: !1
        }) : d.setData({
          attractDay: !0,
          attract: t.data
        })
      }))),
      2 == d.data.date && (d.setData({
        section: !0,
        daily: !1
      }), a.request({
        url: "https://www.qlsyyun.com:3000/trader/branch",
        data: {
          month: d.data.month,
          arr: 1
        }
      }).then((function (t) {
        0 == t.data.length ? d.setData({
          attractDay: !1
        }) : d.setData({
          attractDay: !0,
          attract: t.data
        })
      })))
  },
  census: function (e) {
    var d = this;
    wx.showLoading({
        title: "加载中"
      }),
      setTimeout((function () {
        wx.hideLoading()
      }), 700),
      d.setData({
        bad: e.target.dataset.bad
      }),
      2 == d.data.bad ? (d.setData({
        section: !0,
        semicircle: !0,
        date: 1,
        daily: !0
      }), a.request({
        url: "https://www.qlsyyun.com:3000/trader/branch",
        data: {
          day: t.default.formatDate(new Date).slice(8, 11),
          arr: 2,
          month: d.data.month
        }
      }).then((function (t) {
        0 == t.data.length ? d.setData({
          attractDay: !1
        }) : d.setData({
          attractDay: !0,
          attract: t.data
        })
      }))) : (d.setData({
        semicircle: !1,
        section: !1,
        daily: !0,
        num: 1
      }), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          year: d.data.nowtime.slice(0, 4),
          month: d.data.nowtime.slice(5, 7),
          day: d.data.nowtime.slice(8, 11),
          arr: 1
        }
      }).then((function (t) {
        t.data.length > 0 ? d.setData({
            total: t.data[0]
          }) : d.setData({
            total: {
              jda: 0
            }
          }),
          a.request({
            url: "https://www.qlsyyun.com:3000/trader/lxb",
            data: {
              year: d.data.nowtime.slice(0, 4),
              month: d.data.nowtime.slice(5, 7),
              day: d.data.nowtime.slice(8, 11),
              arr: 1
            }
          }).then((function (t) {
            0 == t.data.length ? d.setData({
              lxb: 0,
              perfumeNum: 1
            }) : d.setData({
              lxb: t.data[0].lxb
            });
            var a = Number((d.data.lxb / d.data.total.jda).toFixed(2));
            d.data.lxb > d.data.total.jda ? d.setData({
              perfumeNum: 2
            }) : d.setData({
              perfumeNum: 1 + a
            })
          }))
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          year: d.data.nowtime.slice(0, 4),
          month: d.data.nowtime.slice(5, 7),
          day: d.data.nowtime.slice(8, 11),
          arr: 2
        }
      }).then((function (t) {
        0 == t.data.length ? d.setData({
          jda: 0,
          jdba: 0,
          jdd: 0
        }) : d.setData({
          jda: t.data[0].jda,
          jdba: t.data[0].jdba,
          jdd: t.data[0].jdd
        })
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          year: d.data.nowtime.slice(0, 4),
          month: d.data.nowtime.slice(5, 7),
          day: d.data.nowtime.slice(8, 11),
          arr: 4
        }
      }).then((function (t) {
        0 == t.data.length ? d.setData({
          attractDay: !1
        }) : d.setData({
          attractDay: !0,
          attract: t.data
        })
      })))
  },
  getDateList: function (t) {
    t.detail
  },
  selectDay: function (t) {
    var e = this;
    2 == e.data.bad ? a.request({
      url: "https://www.qlsyyun.com:3000/trader/branch",
      data: {
        day: t.detail.day,
        arr: 2,
        month: t.detail.month
      }
    }).then((function (t) {
      0 == t.data.length ? e.setData({
        attractDay: !1
      }) : e.setData({
        attractDay: !0,
        attract: t.data,
        daily: !0
      })
    })) : (e.setData({
      hemingday: t.detail.day
    }), a.request({
      url: "https://www.qlsyyun.com:3000/trader",
      data: {
        year: t.detail.year,
        month: t.detail.month,
        day: t.detail.day,
        arr: 1
      }
    }).then((function (d) {
      d.data.length > 0 ? e.setData({
          total: d.data[0]
        }) : e.setData({
          total: {
            jda: 0
          }
        }),
        a.request({
          url: "https://www.qlsyyun.com:3000/trader/lxb",
          data: {
            year: t.detail.year,
            month: t.detail.month,
            day: t.detail.day,
            arr: 1
          }
        }).then((function (t) {
          0 == t.data.length ? e.setData({
            lxb: 0,
            perfumeNum: 1
          }) : e.setData({
            lxb: t.data[0].lxb
          });
          var a = Number((e.data.lxb / e.data.total.jda).toFixed(2));
          e.data.lxb > e.data.total.jda ? e.setData({
            perfumeNum: 2
          }) : e.setData({
            perfumeNum: 1 + a
          })
        }))
    })), a.request({
      url: "https://www.qlsyyun.com:3000/trader",
      data: {
        year: t.detail.year,
        month: t.detail.month,
        day: t.detail.day,
        arr: 2
      }
    }).then((function (t) {
      0 == t.data.length ? e.setData({
        jda: 0,
        jdba: 0,
        jdd: 0
      }) : e.setData({
        jda: t.data[0].jda,
        jdba: t.data[0].jdba,
        jdd: t.data[0].jdd
      })
    })), a.request({
      url: "https://www.qlsyyun.com:3000/trader",
      data: {
        year: t.detail.year,
        month: t.detail.month,
        day: t.detail.day,
        arr: 4
      }
    }).then((function (t) {
      0 == t.data.length ? e.setData({
        attractDay: !1
      }) : e.setData({
        attractDay: !0,
        attract: t.data
      })
    })))
  },
  lastmonth: function () {
    var t = this;
    wx.showLoading({
        title: "加载中"
      }),
      setTimeout((function () {
        wx.hideLoading()
      }), 300),
      t.data.month > 1 && t.setData({
        month: Number(t.data.month) - 1
      }),
      2 == t.data.bad && 2 == t.data.date ? a.request({
        url: "https://www.qlsyyun.com:3000/trader/branch",
        data: {
          month: t.data.month,
          arr: 1
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          attractDay: !1
        }) : t.setData({
          attractDay: !0,
          attract: a.data
        })
      })) : 1 == t.data.bad && (a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 3
        }
      }).then((function (e) {
        e.data.length > 0 ? t.setData({
            total: {
              jda: e.data[0].jda
            }
          }) : t.setData({
            total: {
              jda: 0
            }
          }),
          a.request({
            url: "https://www.qlsyyun.com:3000/trader/lxb",
            data: {
              month: t.data.month,
              arr: 2
            }
          }).then((function (a) {
            if (0 == a.data.length)
              t.setData({
                lxb: 0,
                perfumeNum: 1
              });
            else {
              t.setData({
                lxb: a.data[0].lxb
              });
              var e = Number((t.data.lxb / t.data.total.jda).toFixed(2));
              t.data.lxb > t.data.total.jda ? t.setData({
                perfumeNum: 2
              }) : t.setData({
                perfumeNum: 1 + e
              })
            }
          }))
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 3
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          jda: 0,
          jdba: 0,
          jdd: 0
        }) : t.setData({
          jda: a.data[0].jda,
          jdba: a.data[0].jdba,
          jdd: a.data[0].jdd
        })
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 5
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          attractDay: !1
        }) : t.setData({
          attractDay: !0,
          attract: a.data
        })
      })))
  },
  nextmonth: function () {
    var t = this;
    wx.showLoading({
        title: "加载中"
      }),
      setTimeout((function () {
        wx.hideLoading()
      }), 300),
      t.data.month < 12 && t.setData({
        month: Number(t.data.month) + 1
      }),
      2 == t.data.bad && 2 == t.data.date ? a.request({
        url: "https://www.qlsyyun.com:3000/trader/branch",
        data: {
          month: t.data.month,
          arr: 1
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          attractDay: !1
        }) : t.setData({
          attractDay: !0,
          attract: a.data
        })
      })) : 1 == t.data.bad && (a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 3
        }
      }).then((function (e) {
        e.data.length > 0 ? t.setData({
            total: {
              jda: e.data[0].jda
            }
          }) : t.setData({
            total: {
              jda: 0
            }
          }),
          a.request({
            url: "https://www.qlsyyun.com:3000/trader/lxb",
            data: {
              month: t.data.month,
              arr: 2
            }
          }).then((function (a) {
            if (0 == a.data.length)
              t.setData({
                lxb: 0,
                perfumeNum: 1
              });
            else {
              t.setData({
                lxb: a.data[0].lxb
              });
              var e = Number((t.data.lxb / t.data.total.jda).toFixed(2));
              t.data.lxb > t.data.total.jda ? t.setData({
                perfumeNum: 2
              }) : t.setData({
                perfumeNum: 1 + e
              })
            }
          }))
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 3
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          jda: 0,
          jdba: 0,
          jdd: 0
        }) : t.setData({
          jda: a.data[0].jda,
          jdba: a.data[0].jdba,
          jdd: a.data[0].jdd
        })
      })), a.request({
        url: "https://www.qlsyyun.com:3000/trader",
        data: {
          month: t.data.month,
          arr: 5
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          attractDay: !1
        }) : t.setData({
          attractDay: !0,
          attract: a.data
        })
      })))
  },
  onLoad: function (t) {
    var a = this;
    wx.createSelectorQuery().select("#perfumeBalance").fields({
      node: !0,
      size: !0
    }).exec((function (t) {
      a.initRing(t)
    }));
    var e = wx.getStorageSync("user");
    a.setData({
      user: e
    })
  },
  initRing: function (t) {
    var a = this,
      e = t[0].node,
      d = e.getContext("2d"),
      n = wx.getSystemInfoSync().pixelRatio;
    e.width = t[0].width * n,
      e.height = t[0].height * n,
      d.scale(n, n);
    d.translate(0, 0),
      function t() {
        d.clearRect(0, 0, e.width, e.height),
          d.beginPath(),
          d.strokeStyle = "#EFEFEF",
          d.lineWidth = 15,
          d.lineCap = "round",
          d.arc(125, 115, 90, Math.PI, 2 * Math.PI, !1),
          d.stroke(),
          d.closePath(),
          d.beginPath(),
          d.lineWidth = 15,
          d.lineCap = "round",
          d.arc(125, 115, 90, Math.PI, a.data.perfumeNum * Math.PI, !1),
          d.strokeStyle = "#3C85F4",
          d.stroke(),
          e.requestAnimationFrame(t)
      }
      ()
  }
});